package com.turman.math_learn

import android.app.Application
import android.util.Log
import com.tencent.smtt.export.external.TbsCoreSettings
import com.tencent.smtt.sdk.QbSdk
import com.tencent.smtt.sdk.WebView


class MyApplication:Application() {
    override fun onCreate() {
        super.onCreate()

        QbSdk.initX5Environment(this, object : QbSdk.PreInitCallback {
            override fun onCoreInitFinished() {
                Log.i("app", "onCoreInitFinished")
            }

            /**
             * 预初始化结束
             * 由于X5内核体积较大，需要依赖网络动态下发，所以当内核不存在的时候，默认会回调false，此时将会使用系统内核代替
             * @param isX5 是否使用X5内核
             */
            override fun onViewInitFinished(isX5: Boolean) {
                Log.i("app", "onViewInitFinished: $isX5")
            }
        })
        QbSdk.setDownloadWithoutWifi(true)

        val map: HashMap<String, Any?> = HashMap()
        map[TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER] = true
        map[TbsCoreSettings.TBS_SETTINGS_USE_DEXLOADER_SERVICE] = true
        QbSdk.initTbsSettings(map as Map<String, Any>?)

        val preloadedWebView = WebView(applicationContext)
        preloadedWebView.loadUrl("about:blank")
    }
}